<template>
  <!-- 清算账户信息查询申请查询明细页面弹出框-->
  <el-dialog
    title="清算账户信息查询申请查询明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="true"
    @close="closeFn"
  >
    <el-form ref="detailsForm" :model="formData" label-width="180px" :disabled="true">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="交易流水号：" prop="id">
            <el-input v-model="formData.id" placeholder="交易流水号" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="报文标识号：" prop="pkgId">
            <el-input v-model="formData.pkgId" placeholder="报文标识号" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="CPG日期：" prop="vdate">
            <el-date-picker
              v-model="formData.vdate"
              type="date"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="工作日期：" prop="workdate">
            <el-date-picker
              v-model="formData.workdate"
              type="date"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="查询方式：" prop="inqType">
            <el-select v-model="formData.inqType" placeholder="请选择" style="width: 100%">
              <el-option
                v-for="dict in dictMap.QUERYACCOUNTCODE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="被查询清算行行号：" prop="inqStBrno">
            <el-input v-model="formData.inqStBrno" placeholder="被查询清算行行号" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="被查询清算行行名：" prop="inqStBrnoName">
            <el-input v-model="formData.inqStBrnoName" placeholder="被查询清算行行名" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="清算账户明细数：" prop="txnNum">
            <el-input v-model="formData.txnNum" placeholder="清算账户明细数" />
          </el-form-item>
        </el-col>
        <el-col :span="12"></el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="附言：" prop="remarks">
            <el-input type="textarea" v-model="formData.remarks" placeholder="附言" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-card class="form-card txnInfo-card">
      <div style="height: 300px">
        <ht-table
          ref="flowTable"
          :showSerialNumber="false"
          :multi-select="false"
          :dictMap="dictMap"
          :reqConfig="reqConfig"
          :queryParams="queryParams"
          :tableBindColumns="tableBindColumns"
          :opButtonList="opButtonList"
          :randomRowKey="true"
          :initData="false"
          defaultEventKey="flowTable"
          style="height: 100%"
        >
          <template v-slot:operate>
            <el-table-column
              label="操作"
              align="center"
              width="120"
              fixed="right"
              class-name="small-padding fixed-width"
            >
              <template slot-scope="scope">
                <ht-button-group
                  :buttonList="[
                    {
                      label: '明细',
                      // permission: 'user:xxx:xxx',
                      doFunc: () => {
                        handleAction('detailsInfo', scope.row);
                      },
                    },
                  ]"
                />
              </template>
            </el-table-column>
          </template>
        </ht-table>
      </div>
    </el-card>

    <!-- 明细操作弹出框 -->
    <table-detail ref="tableDetailDialog" :dictMap="dictMap" :detailsData="detailsData"></table-detail>
  </el-dialog>
</template>
<script>
import { detailsearch } from "@/api/cnaps/saps/clearAcctInfoQuery/clear_inquiry_query.js";
import TableDetail from "./tableDetail";
export default {
  name: "QueryDetails",
  components: {
    TableDetail,
  },
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      detailsData: {}, // 明细操作传值
      // 是否显示弹出层
      open: false,
      reqConfig: detailsearch,
      // 查询参数
      queryParams: {
        id: "",
      },
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        {
          label: `参与机构大类`,
          prop: "orgClass",
          width: "200",
          dictCode: "PARTYCATEGORYCODE",
          sortable: false,
        },
        {
          label: `清算行行号`,
          prop: "stBrno",
          width: "200",
          sortable: false,
        },
        {
          label: `清算行名称`,
          prop: "stBrName",
          width: "200",
          sortable: false,
        },
        {
          label: `账户状态`,
          prop: "actStatus",
          dictCode: "ACCOUNTSTATUSCODE",
          sortable: false,
        },
      ],
    };
  },
  mounted() {},
  watch: {
    open(d) {
      if (d) {
        this.$nextTick(() => {
          if (this.formData && this.formData.id) {
            this.$set(this.queryParams, "id", this.formData.id);
            this.$refs.flowTable.doQuery();
          }
        });
      }
    },
  },
  methods: {
    // 表单重置
    reset() {
      this.resetForm("detailsForm");
      // this.$set(this, "form", {});
    },
    closeFn() {
      this.open = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "detailsInfo":
          // 设置
          this.detailsData = _.clone(row);
          this.$refs.tableDetailDialog.show();
          break;
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
